package com.ruoyi.project.dataviewSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dataviewSystem.domain.VWarning;
import com.ruoyi.project.dataviewSystem.service.IVWarningService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 实时，暂忽，历史告警Controller
 * 
 * @author wangshuo
 * @date 2021-02-08
 */
@RestController
@RequestMapping("/dataviewSystem/warningdata")
public class VWarningController extends BaseController
{
    @Autowired
    private IVWarningService vWarningService;

    /**
     * 查询实时，暂忽，历史告警列表
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(VWarning vWarning)
    {
        startPage();
        List<VWarning> list = vWarningService.selectVWarningList(vWarning);
        return getDataTable(list);
    }

    /**
     * 导出实时，暂忽，历史告警列表
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:export')")
    @Log(title = "实时，暂忽，历史告警", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VWarning vWarning)
    {
        List<VWarning> list = vWarningService.selectVWarningList(vWarning);
        ExcelUtil<VWarning> util = new ExcelUtil<VWarning>(VWarning.class);
        return util.exportExcel(list, "warningdata");
    }

    /**
     * 获取实时，暂忽，历史告警详细信息
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vWarningService.selectVWarningById(id));
    }

    /**
     * 新增实时，暂忽，历史告警
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:add')")
    @Log(title = "实时，暂忽，历史告警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VWarning vWarning)
    {
        return toAjax(vWarningService.insertVWarning(vWarning));
    }

    /**
     * 修改实时，暂忽，历史告警
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:edit')")
    @Log(title = "实时，暂忽，历史告警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VWarning vWarning)
    {
        return toAjax(vWarningService.updateVWarning(vWarning));
    }

    /**
     * 删除实时，暂忽，历史告警
     */
    @PreAuthorize("@ss.hasPermi('dataviewSystem:warningdata:remove')")
    @Log(title = "实时，暂忽，历史告警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vWarningService.deleteVWarningByIds(ids));
    }
}
